package main

import (
	"fmt"
	"net"
	"net/rpc"
	"time"
)

type S struct{}

type Reply struct {
	Msg []byte
}

func (s *S) Recv(nul *struct{}, reply *Reply) error {
	fmt.Println(*nul)
	*reply = Reply{[]byte("foo")}
	time.Sleep(time.Duration(5) * time.Second)
	return nil
}

func main() {
	err := rpc.Register(new(S))
	if err != nil {
		fmt.Println("failed to register publisher: ", err)
	}
	listen, err := net.Listen("tcp", "127.0.0.1:2015")
	if err != nil {
		fmt.Println("failed to listen tcp:", err)
	}
	defer listen.Close()
	rpc.Accept(listen)
}
